package com.ld.admin.util.daliySentence.impl;

import com.alibaba.fastjson.JSONObject;
import com.ld.admin.util.daliySentence.DaliySentence;
import com.ld.shieldsb.common.core.util.JsoupUtil;

/**
 * 
 * 木芽一言
 * 
 * @author <a href="mailto:donggongai@126.com" target="_blank">吕凯</a>
 * @date 2020年1月8日 上午11:00:38
 *
 */
public class DaliySentenceDailywd implements DaliySentence {
    public static final String URL = "https://api.xygeng.cn/one"; // 木芽一言
    public static final String IMAGE_1366 = "https://api.xygeng.cn/bing/1366.php"; // 必应每日一图API,1366*768分辨率
    public static final String IMAGE_1920 = "https://api.xygeng.cn/bing/1920.php"; // 必应每日一图API,1920*1080分辨率

    @Override
    public String getSentence() {
        String content = null;
        JSONObject jsonObj = JsoupUtil.getRemoteURLJson(URL);
        /*{
            "code": 200,
            "data": {
                "id": "807",
                "tag": "漫画",//主题
                "origin": "《萤火之森》",//来自
                "content": "其实美丽的故事都是没有结局的，只因为它没有结局所以才会美丽。",//内容
                "datetime": "1548230343"
            }
        }*/
        if (jsonObj != null) {
            JSONObject dataResult = jsonObj.getJSONObject("data");
            String origin = dataResult.getString("origin");
            content = dataResult.getString("content") + "——" + origin + "【来自<a href='http://api.xygeng.cn' target='_blank'>「木芽一言」</a>】";
        }
        return content;
    }

}
